package cn.wowjoy.pda.android_pharmacy.mvvm.vm;

import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import cn.bingoogolapple.androidcommon.adapter.BGABindingRecyclerViewAdapter;
import cn.wowjoy.pda.android_pharmacy.R;
import cn.wowjoy.pda.android_pharmacy.common.core.BaseViewModel;
import cn.wowjoy.pda.android_pharmacy.databinding.ItemRvDoorputMedicineBinding;
import cn.wowjoy.pda.android_pharmacy.model.xmlEntity.putInfo.PutSingleBeen;

/**
 * Created by sinyo on 2017/7/25.
 */

public class DoorPutDetailViewModel  extends BaseViewModel {
    public ArrayList<PutSingleBeen> datas;
//    public ArrayList<PutSingleBeen> acceptBack=;

    public BGABindingRecyclerViewAdapter<PutSingleBeen, ItemRvDoorputMedicineBinding> wlinnerAdapter = new BGABindingRecyclerViewAdapter<>(R.layout.item_rv_doorput_medicine);
    public LRecyclerViewAdapter wladapter = new LRecyclerViewAdapter(wlinnerAdapter);


    public void setWData(List<PutSingleBeen> data) {
        if (null == datas)
            datas = new ArrayList<>();
        datas.clear();
        Iterator<PutSingleBeen> iterator = data.iterator();
        while (iterator.hasNext()){
            PutSingleBeen next = iterator.next();
            if(! next.isPut()){
                iterator.remove();
                datas.add(next);
            }
        }
        datas.addAll(data);
        wlinnerAdapter.setData(datas);
        wladapter.removeFooterView();
        wladapter.removeHeaderView();
        wladapter.notifyDataSetChanged();
    }
    public boolean show(){
        if(null != datas && datas.size()>0){
            for(PutSingleBeen p : datas){
                if(p.isPut()){
                    return true;
                }
            }
        }
        return false;
    }
}
